//---------------------------------------------------------------------------


#pragma hdrstop

#include "TElementSerialNumber.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

bool __fastcall TElementSerialNumber::SetElementSerialNumber(const AnsiString UserID,
															 const eElementType ElementType)
{
	static int Number = 0;
	int sl = 10;
	AnsiString S, s;
	S = UserID;
	if (S.Length() < sl) {
		s = s.StringOfChar('*', sl - S.Length());
		S += s;
	} else
   	S = S.SubString(0, sl);
	s = Now().FormatString("yyyymmddhhnnss");
	S = S + s;
	s = s.sprintf("%2.2d%5.5d", ElementType, Number);
	SerialNumber = S + s;
	Number++;
	return true;
}

TElementSerialNumber & TElementSerialNumber::operator = (TElementSerialNumber t)
{
	SerialNumber = t.SerialNumber;
	Name = t.Name;
	Note = t.Note;
	Index = t.Index;
	return *this;
}

__fastcall TElementSerialNumbers::TElementSerialNumbers()
{

}

TElementSerialNumbers & TElementSerialNumbers::operator = (TElementSerialNumbers t)
{
	clear();
	for (int i = 0; i < t.size(); i++)
		push_back(t[i]);
	return *this;
}
//	TElementSerialNumbers operator = (TElementSerialNumbers t);
																/*
TElementSerialNumbers TElementSerialNumbers::operator = (TElementSerialNumbers t)
{
	TElementSerialNumbers ss;
	for (int i = 0; i < t.size(); i++)
		ss.push_back(t[i]);
	return ss;
}                                                              */

bool __fastcall TElementSerialNumbers::InList(const AnsiString SerialNumber)
{
	for (int i = 0; i < size(); i++) {
		if (at(i) == SerialNumber) {
			return true;
		}
	}
	return false;
}






